import { EntitySchema } from '@mikro-orm/core';

export class ImsYzdKpUsers {
  id!: number;
  nickName!: string;
  avatarUrl!: unknown;
  trueName?: string;
  birthday?: string;
  gender: boolean = false;
  wxappOpenid!: string;
  wxh5Openid!: string;
  bdappOpenid!: string;
  ttappOpenid!: string;
  isH5?: boolean = false;
  isApp?: boolean = false;
  phone!: string;
  password!: string;
  salt!: string;
  regtime!: string;
  lastTime!: string;
  state: boolean = true;
  note?: unknown;
  pid: number = 0;
  isDistributor: number = 1;
  uniacid!: number;
  unionid!: string;
  isUser: boolean = false;
  lid: number = 0;
}

export const ImsYzdKpUsersSchema = new EntitySchema({
  class: ImsYzdKpUsers,
  properties: {
    id: { primary: true, type: 'number' },
    nickName: { type: 'string', fieldName: 'nickName', length: 255 },
    avatarUrl: { type: 'unknown', fieldName: 'avatarUrl', columnType: 'longtext' },
    trueName: { type: 'string', fieldName: 'trueName', length: 255, nullable: true },
    birthday: { type: 'string', length: 255, nullable: true },
    gender: { type: 'boolean', default: false, index: 'gender' },
    wxappOpenid: { type: 'string', length: 255 },
    wxh5Openid: { type: 'string', fieldName: 'wxh5_openid', length: 255 },
    bdappOpenid: { type: 'string', length: 255 },
    ttappOpenid: { type: 'string', length: 255 },
    isH5: { type: 'boolean', nullable: true, default: false },
    isApp: { type: 'boolean', nullable: true, default: false },
    phone: { type: 'string', length: 255 },
    password: { type: 'string', length: 255 },
    salt: { type: 'string', length: 255 },
    regtime: { type: 'string', length: 255 },
    lastTime: { type: 'string', length: 255 },
    state: { type: 'boolean', default: true, index: 'state' },
    note: { type: 'unknown', columnType: 'longtext', nullable: true },
    pid: { type: 'number', default: 0, index: 'pid' },
    isDistributor: { type: 'number', default: 1, index: 'is_distributor' },
    uniacid: { type: 'number' },
    unionid: { type: 'string', length: 255, default: '0' },
    isUser: { type: 'boolean', default: false },
    lid: { type: 'number', default: 0, index: 'lid' },
  },
});
